package com.huang.strategic.v1;

import java.math.BigDecimal;

/**
 * <p>满多少返利多少</p>
 *
 * @author aneng huang
 * @since 2020-10-27 15:21:34
 */
public class CashierReturn implements CashierSuper {

    private double moneyCondition = 0;
    private double moneyReturn = 0;

    public CashierReturn(String moneyCondition, String moneyReturn) {
        this.moneyCondition = new BigDecimal(moneyCondition).doubleValue();
        this.moneyReturn = new BigDecimal(moneyReturn).doubleValue();
    }

    @Override
    public double acceptCash(double money) {
        if (moneyCondition == 0) {
            return money - moneyReturn;
        }
        if (money >= moneyCondition) {
            int b = (int) (money/moneyCondition);
            return money - (b * moneyReturn);
        }
        return money;
    }
}
